<template>
  <div class="px-4">
    <uni-title class="mt-4" type="h2" title="产品建议" />
    <text class="text-gray-500">安全扫码专业委员会</text>

    <!-- <uni-collapse ref="collapse">
      <uni-collapse-item :show-arrow="false">
        <template #title>
          <uni-title class="mt-4" type="h2" title="反馈类别" />
        </template>
        <uni-data-checkbox mode="list" v-model="radio" :localdata="typeList" />
      </uni-collapse-item>
    </uni-collapse> -->

    <uni-title class="mt-4" type="h2" title="详细描述" />
    <textarea
      type="textarea"
      class="w-full p-2 border-gray-300 rounded-sm"
      v-model="textValue"
      placeholder="请输入详细描述内容"
    />

    <div
      class="mt-10 rounded-full h-10 bg-blue-500 text-center text-white font-semibold text-lg"
      style="line-height: 40px"
      @click="postSuggest"
    >
      提交反馈
    </div>
  </div>
</template>

<script setup lang="ts">
  import { useHttp } from '@/request/request'
  import { ref } from 'vue'
  const {  post } = useHttp()

  const q = JSON.parse(uni.getStorageSync('query')) as {
    ewm: '1',
    count: '96',
    num: '239',
    bid: '33547',
    unionid: 'oSqUJ0uLmgiz7Q-pMwQkIMaRpdls',
    openid: 'oPbPOw6Sk6oGl5KaX9UKEpuCpKrw',
    bname: '孜然界烧烤张湾店',
    sn: '222110785161563278',
    mac: '',
  }



  const radio = ref('1')
  const textValue = ref('')
  const primary = 'primary' as any

  const postSuggest = async () => {
    const { bid, openid } = q
    if (!textValue.value) {
      uni.showToast({
        title: `请您填写内容在提交`,
        icon: 'none',
      })
      return
    }

    const res = await post('index/feedback', {
      bid,
      openid,
      content: textValue.value,
    })

    uni.showModal({
      title: '成功',
      content: res.code == 1 ? res.msg : '反馈失败，请稍后重试',
    })
  }

  const typeList = [
    { value: '1', text: '功能异常' },
    { value: '2', text: '体验问题' },
    { value: '3', text: '新功能建议' },
    { value: '4', text: '其他' },
  ]
</script>

<style scoped>
  .uni-collapse-item__wrap {
    background-color: rgba(red, green, blue, 0) !important;
  }

  .uni-collapse[data-v-a0fbf47b] {
    background-color: rgba(red, green, blue, 0) !important;
  }
</style>
